package main

import (
	"andals/gobox/shell"
	"dockerbox/conf"
	"dockerbox/pkg/misc"
	"flag"
	"fmt"
	"os"
)

func main() {
	defer func() {
		err := recover()
		if err != nil {
			fmt.Println(err)
		}
	}()

	var dconfPath string
	misc.SetCommonFlag(&dconfPath)
	flag.Parse()

	if flag.NArg() < 1 {
		panic("Usage: " + os.Args[0] + " cname")
	}

	conf.Init(dconfPath)

	key := flag.Arg(0)
	cconf := conf.GetContainerConf(key)

	cmd := "sudo nsenter --target `docker inspect --format {{.State.Pid}} " + cconf.ContainerName + "` --mount --uts --ipc --net --pid"
	shell.RunCmdBindTerminal(cmd)
}
